<?php

class MDanhMucSanPham extends CI_Model
{
	function danhsachdanhmucsanpham()
	{
		$this->db->where('hienthi', 'true');
		return $this->db->get('danhmucsp')->result();
	}
	
function danhsachdanhmucAdmin()
	{
		return $this->db->get('danhmucsp')->result();
	}
	
	function themdanhmuc($tendm, $hienthi)
	{
		$this->db->set('tendm', $tendm);
		$this->db->set('hienthi', $hienthi);
		$this->db->insert('danhmucsp');
	}
	
	function danhsachdanhmuc()
	{
		$this->db->where('hienthi', 'true');
		return $this->db->get('danhmucsp')->result();
	}
	
	function xoadanhmuc($madm)
	{
		$this->db->where('madm', $madm);
		$this->db->delete('danhmucsp');
	}
	
	function capnhat($madm, $tendm, $hienthi)
	{
		$this->db->where('madm', $madm);
		$this->db->set('tendm', $tendm);
		$this->db->set('hienthi', $hienthi);
		$this->db->update('danhmucsp');
	}
	
	function thongtindanhmuc($madm)
	{
		$this->db->where('madm', $madm);
		 return $this->db->get('danhmucsp')->row();
	}
	
}

?>